<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>过滤器</title>
    <script src="./lib/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <!--  使用过滤器 -->
      <img :src="imgsrc | dataFormat" alt="" />
    </div>
  </body>
  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        imgsrc: "01.jpg"
      },
      //定义局部过滤器，注意加filter加s
      filters: {
        dataFormat(msg) {
          return "img/" + msg;
        }
      }
    });
  </script>
</html>
